package main

import (
	"demo/router"
	"github.com/gin-gonic/gin"
	"log"
)

func main()  {

	gin.SetMode(gin.ReleaseMode)

	engine := gin.New()
	// 注册路由
	router.Register(engine)

	//server := endless.NewServer(":3333", engine)
	//// 注册程序终止信号
	//signals := []os.Signal{
	//	syscall.SIGHUP,
	//	syscall.SIGUSR1,
	//	syscall.SIGUSR2,
	//	syscall.SIGINT,
	//	syscall.SIGTERM,
	//	syscall.SIGTSTP,
	//}
	//for _, signal := range signals {
	//	_ = server.RegisterSignalHook(endless.PRE_SIGNAL, signal, func() {
	//
	//	})
	//}
	//server.BeforeBegin = func(add string) {
	//	log.Printf("Actual pid is %d", syscall.Getpid())
	//}

	//err := server.ListenAndServe()
	//if err != nil {
	//	log.Printf("Server err: %v", err)
	//}

	err := engine.Run(":3333")
	if err != nil {
		log.Printf("Server err: %v", err)
	}
}
